#include "hash.h"

class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        unordered_set<int> h;
        vector<int> res;
        for (auto e : nums1) h.insert(e);
        
        for (auto e : nums2)
        {
            if (h.find(e) == h.end()) continue;
            res.push_back(e);
            //h.erase(e);// 给数组去重
            h.erase(h.find(e));
        }

        return res;
    }
};